Reduce includes of gtkfilesystem.h
authorMatthias Clasen <mclasen@redhat.com>
Sat, 11 Jul 2020 22:11:32 +0000 (18:11 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 12 Jul 2020 13:12:43 +0000 (09:12 -0400)
Move a few non-filesystem helpers to gtkfileutils.h,
and drop the include in all the places where it isn't needed.

14 files changed:
gtk/gtkfilechooserdialog.c
gtk/gtkfilechooserentry.c
gtk/gtkfilechooserentry.h
gtk/gtkfilechoosernative.c
gtk/gtkfilechoosernativeportal.c
gtk/gtkfilechoosernativequartz.c
gtk/gtkfilechoosernativewin32.c
gtk/gtkfilechooserutils.c
gtk/gtkfilechooserutils.h
gtk/gtkfilesystem.c
gtk/gtkfilesystem.h
gtk/gtkfilesystemmodel.c
gtk/gtknativedialog.c
gtk/gtkplacessidebar.c

index a7bc1dd15f21d2202b2e37b938b2b0508290b853..d27ba8e3c07fe2102062d17955531249a5a69e4d 100644 (file)
@@ -26,7 +26,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
index 695d3db352de65151da26c9dccb2d16e66892c2e..97e36f099409a8a1b7f5ffacd68685244ef02e0e 100644 (file)
@@ -25,7 +25,7 @@
 #include "gtkcelllayout.h"
 #include "gtkcellrenderertext.h"
 #include "gtkentryprivate.h"
-#include "gtkfilesystemmodel.h"
+#include "gtkfilechooserutils.h"
 #include "gtklabel.h"
 #include "gtkmain.h"
 #include "gtksizerequest.h"
index fb6725e9c9f580f2831a0d43dff0e7090dd8fbcb..e1ed9f73042c2a7671a6e995c9bb5f21e7304ee8 100644 (file)
@@ -19,7 +19,6 @@
 #ifndef __GTK_FILE_CHOOSER_ENTRY_H__
 #define __GTK_FILE_CHOOSER_ENTRY_H__
 
-#include "gtkfilesystem.h"
 #include "gtkfilechooser.h"
 
 G_BEGIN_DECLS
index b6f7a9b01b3a2fa9119f5d1676ff65910721e425..d157dfa0022f62d198ca7c0d08a7b6bdaff943ea 100644 (file)
@@ -29,7 +29,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
index d14a28cb349b7a80b34876cf06af6ac2e9e31088..1aafd3d9fcf0be23e03a96bd3116878d1f7c23ed 100644 (file)
@@ -29,7 +29,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
index d7cf4113a47d7e194c533380d7eeff12a749b107..1726942b9713ce8f3e72f88497b981626388187b 100644 (file)
@@ -29,7 +29,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
index 66157ccd69ed62f9ae6dd5e493de5f52c9032582..9b435060424e77401858c0f2719f79f3e2f275de 100644 (file)
@@ -35,7 +35,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
index 0c62e8d590db3b4210280058418f4ff5041575b5..4f5891fca8cbecdbb6e9c59eca9af7a6b889afee 100644 (file)
@@ -411,3 +411,76 @@ delegate_get_choice (GtkFileChooser  *chooser,
 {
   return gtk_file_chooser_get_choice (get_delegate (chooser), id);
 }
+
+gboolean
+_gtk_file_info_consider_as_directory (GFileInfo *info)
+{
+  GFileType type = g_file_info_get_file_type (info);
+
+  return (type == G_FILE_TYPE_DIRECTORY ||
+          type == G_FILE_TYPE_MOUNTABLE ||
+          type == G_FILE_TYPE_SHORTCUT);
+}
+
+gboolean
+_gtk_file_has_native_path (GFile *file)
+{
+  char *local_file_path;
+  gboolean has_native_path;
+
+  /* Don't use g_file_is_native(), as we want to support FUSE paths if available */
+  local_file_path = g_file_get_path (file);
+  has_native_path = (local_file_path != NULL);
+  g_free (local_file_path);
+
+  return has_native_path;
+}
+
+gboolean
+_gtk_file_consider_as_remote (GFile *file)
+{
+  GFileInfo *info;
+  gboolean is_remote;
+
+  info = g_file_query_filesystem_info (file, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE, NULL, NULL);
+  if (info)
+    {
+      is_remote = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE);
+
+      g_object_unref (info);
+    }
+  else
+    is_remote = FALSE;
+
+  return is_remote;
+}
+
+GIcon *
+_gtk_file_info_get_icon (GFileInfo *info,
+                         int        icon_size,
+                         int        scale)
+{
+  GIcon *icon;
+  GdkPixbuf *pixbuf;
+  const gchar *thumbnail_path;
+
+  thumbnail_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
+
+  if (thumbnail_path)
+    {
+      pixbuf = gdk_pixbuf_new_from_file_at_size (thumbnail_path,
+                                                 icon_size*scale, icon_size*scale,
+                                                 NULL);
+
+      if (pixbuf != NULL)
+        return G_ICON (pixbuf);
+    }
+
+  icon = g_file_info_get_icon (info);
+  if (icon)
+    return g_object_ref (icon);
+
+  /* Use general fallback for all files without icon */
+  icon = g_themed_icon_new ("text-x-generic");
+  return icon;
+}
index 3ca736c996aaf34bdced4da89d621a1abd88f3f6..43041e2885c13efba9579e9359b4c13597600770 100644 (file)
@@ -49,6 +49,13 @@ GSettings *_gtk_file_chooser_get_settings_for_widget (GtkWidget *widget);
 
 gchar * _gtk_file_chooser_label_for_file (GFile *file);
 
+gboolean        _gtk_file_info_consider_as_directory (GFileInfo *info);
+gboolean        _gtk_file_has_native_path (GFile *file);
+gboolean        _gtk_file_consider_as_remote (GFile *file);
+GIcon *               _gtk_file_info_get_icon    (GFileInfo *info,
+                                                  int        icon_size,
+                                                  int        scale);
+
 G_END_DECLS
 
 #endif /* __GTK_FILE_CHOOSER_UTILS_H__ */
index 4e71446d692bcd5fbfc0fbe5258f66c78c2cfdd4..c7bdc0e68f99c85c085732b201840a95b2db3c5e 100644 (file)
@@ -747,77 +747,3 @@ _gtk_file_system_volume_unref (GtkFileSystemVolume *volume)
       G_IS_DRIVE (volume))
     g_object_unref (volume);
 }
-
-/* GFileInfo helper functions */
-GIcon *
-_gtk_file_info_get_icon (GFileInfo *info,
-                        int        icon_size,
-                         int        scale)
-{
-  GIcon *icon;
-  GdkPixbuf *pixbuf;
-  const gchar *thumbnail_path;
-
-  thumbnail_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
-
-  if (thumbnail_path)
-    {
-      pixbuf = gdk_pixbuf_new_from_file_at_size (thumbnail_path,
-                                                icon_size*scale, icon_size*scale,
-                                                NULL);
-
-      if (pixbuf != NULL)
-        return G_ICON (pixbuf);
-    }
-
-  icon = g_file_info_get_icon (info);
-  if (icon)
-    return g_object_ref (icon);
-
-  /* Use general fallback for all files without icon */
-  icon = g_themed_icon_new ("text-x-generic");
-  return icon;
-}
-
-gboolean
-_gtk_file_info_consider_as_directory (GFileInfo *info)
-{
-  GFileType type = g_file_info_get_file_type (info);
-  
-  return (type == G_FILE_TYPE_DIRECTORY ||
-          type == G_FILE_TYPE_MOUNTABLE ||
-          type == G_FILE_TYPE_SHORTCUT);
-}
-
-gboolean
-_gtk_file_has_native_path (GFile *file)
-{
-  char *local_file_path;
-  gboolean has_native_path;
-
-  /* Don't use g_file_is_native(), as we want to support FUSE paths if available */
-  local_file_path = g_file_get_path (file);
-  has_native_path = (local_file_path != NULL);
-  g_free (local_file_path);
-
-  return has_native_path;
-}
-
-gboolean
-_gtk_file_consider_as_remote (GFile *file)
-{
-  GFileInfo *info;
-  gboolean is_remote;
-
-  info = g_file_query_filesystem_info (file, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE, NULL, NULL);
-  if (info)
-    {
-      is_remote = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE);
-
-      g_object_unref (info);
-    }
-  else
-    is_remote = FALSE;
-
-  return is_remote;
-}
index c734dfcede5d402d6be7a76c2a1ebd12780161b3..62a82d6537b9d1e42d5d09f225305afaddf4bb41 100644 (file)
@@ -99,18 +99,7 @@ GIcon *               _gtk_file_system_volume_get_icon          (GtkFileSystemVo
 GtkFileSystemVolume  *_gtk_file_system_volume_ref              (GtkFileSystemVolume *volume);
 void                  _gtk_file_system_volume_unref            (GtkFileSystemVolume *volume);
 
-/* GFileInfo helper functions */
-GIcon *               _gtk_file_info_get_icon    (GFileInfo *info,
-                                                  int        icon_size,
-                                                  int        scale);
-
-gboolean       _gtk_file_info_consider_as_directory (GFileInfo *info);
-
-/* GFile helper functions */
-gboolean       _gtk_file_has_native_path (GFile *file);
-
-gboolean        _gtk_file_consider_as_remote (GFile *file);
-
 G_END_DECLS
 
 #endif /* __GTK_FILE_SYSTEM_H__ */
+
index 006cb1252b0eebf020120b3aaefa3a0b71aea5c0..a541b88ba987f86ceb436a1523cebee208e78c6c 100644 (file)
@@ -23,7 +23,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "gtkfilesystem.h"
+#include "gtkfilechooserutils.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
 #include "gtktreedatalist.h"
index 784455e1187f62abc54bc17a51997cfbf7cef9b4..1ba13798c584dfc583d0c97f87d35d30110c10fa 100644 (file)
@@ -28,7 +28,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
index 1131668f5837e5fe18a37743b714b466ee8ebc5f..7c528252e2b65bf9aae489f2ac412b3f9cc3e2a4 100644 (file)
@@ -33,7 +33,7 @@
 #include "gdk/gdkkeysyms.h"
 #include "gtkbookmarksmanagerprivate.h"
 #include "gtkcelllayout.h"
-#include "gtkfilesystem.h"
+#include "gtkfilechooserutils.h"
 #include "gtkicontheme.h"
 #include "gtkintl.h"
 #include "gtkmain.h"